capture log close
clear all
set maxvar 10000
set more off
pause on
# delimit;

local manasi "";
local output "";
local log "";
local data "";
local earn "";

log using "`log'\restat_analysis_rd_earn_polyest2.log", replace;


/* 
Manasi Deshpande, 09/02/2014
RD plots
*/

local exp "entry04rd";
local time "wk";
local unit "weekly";
local tlabel_dte "01oct2000 01jan2001 01apr2001 01jul2001 01oct2001 01jan2002 01apr2002 01jul2002 01oct2002, format(%tdmd)";
local tlabel_wk "2001w1 2001w14 2001w27 2001w40 2002w1 2002w14 2002w27";
local tline_dte "01oct2001";
local tline_wk "2001w40";

local title_fy_2004 "Eligible for CDR in FY2004";
local title_n_cdr_rel "CDR Release";
local title_n_cdrunfav_18 "Unfavorable CDR";
local title_n_paymon18 "Months on SSI";
local title_n_combpay18 "Total SSI payment";
local title_n_avgpay18 "Average annual SSI payment";
local title_n_paymonpre "Pre-treatment months on SSI";
local title_n_combpaypre "Pre-treatment SSI payment";
local title_n_hhunearn "Total household unearned income";
local title_n_hhunearn0206 "Total household unearned income";
local title_n_hhunearnwokid "Household unearned income (w/o child)";
local title_n_hhunearnwokid0206 "Household unearned income (w/o child)";
local title_n_hhdiamt "Parental DI receipt";
local title_n_hhdiamt0206 "Parental DI receipt";
local title_n_hhnumdi "Number of parents on DI";
local title_n_hhnumdi0206 "Number of parents on DI";
local title_n_hhssipay "Parental SSI receipt";
local title_n_hhssipay0206 "Parental SSI receipt";
local title_n_hhnumssi "Number of parents on SSI";
local title_n_hhnumssi0206 "Number of parents on SSI";
local title_n_sibssipay "Sibling SSI receipt";
local title_n_sibnumssi "Number of siblings on SSI";
local title_n_hhappdi "Number of parental DI apps";
local title_n_hhappdi0206 "Number of parental DI apps";
local title_n_hhappssi "Number of parental SSI apps";
local title_n_hhappssi0206 "Number of parental SSI apps";
local title_n_kidappdi "Number of child DI apps";
local title_n_kidappssi "Number of child SSI apps";
local title_n_sibappnum "Number of sibling SSI apps";
forval yr=1985(1)2012 {; 
	local title_n_paymon_`yr' "Months on SSI in `yr'";
	local title_n_combpay_`yr' "Child's SSI payment in `yr'";
	local title_n_hhcombpay_`yr' "Parental SSI receipt in `yr'";
	local title_n_hhcombpay0206_`yr' "Parental SSI receipt in `yr'";
	local title_n_sibpayall_`yr' "Sibling SSI receipt in `yr'";
	local title_n_par831di_`yr' "Parental DI app in `yr'";
	local title_n_par831ssi_`yr' "Parental SSI app in `yr'";
	local title_n_kid831_di_`yr' "Kid applies for DI in `yr'";
	local title_n_kid831_ssi_`yr' "Kid applies for SSI in `yr'";
};
local title_n_male "Male";
local title_cdr_dobyy "Year of birth";
local title_n_fiscalyob "Fiscal year of birth";
forval yr=1991(1)2004 {;
	local title_n_yob_`yr' "Year of birth `yr'";
	local title_n_fiscalyob_`yr' "Fiscal YOB `yr'";
};
local title_n_firstage "Age at initial SSI receipt";
forval i=0(1)11 {;
	local title_n_firstage_`i' "Age `i' at initial SSI receipt";
};
local title_n_diag1_none "No diagnosis";
local title_n_diag1_infec "Infectious diagnosis";
local title_n_diag1_neo "Neoplasm diagnosis";
local title_n_diag1_endo "Endocrine diagnosis";
local title_n_diag1_blood "Blood diagnosis";
local title_n_diag1_mental "Mental diagnosis";
local title_n_diag1_nerv "Nervous diagnosis";
local title_n_diag1_sense "Sensory diagnosis";
local title_n_diag1_circ "Circulatory diagnosis";
local title_n_diag1_resp "Respiratory diagnosis";
local title_n_diag1_dig "Digestive diagnosis";
local title_n_diag1_gu "GU diagnosis";
local title_n_diag1_skin "Skin diagnosis";
local title_n_diag1_musc "Musculoskeletal diagnosis";
local title_n_diag1_cong "Congenital diagnosis";
local title_n_diag1_nat "Natal diagnosis";
local title_n_diag1_ill "Ill-defined diagnosis";
local title_n_diag1_inj "Injury diagnosis";

local title_n_kidearnstot18 "Child's earnings in adulthood";
local title_n_kidearnsavg18 "Child's earnings in adulthood";
local title_n_combpaytot18 "Child's SSI payment in adulthood";
local title_n_combpayavg18 "Child's SSI payment in adulthood";
local title_n_hhearn18 "Parental earnings to age 18";
local title_n_hhearn020618 "Parental earnings to age 18";
local title_n_hhearnpost04 "Parental earnings";
local title_n_hhearn0206post04 "Parental earnings";
local title_n_hhearnpost03 "Parental earnings";
local title_n_hhearn0206post03 "Parental earnings";
local title_n_hhearnpre04 "Pre-treatment household earnings";
local title_n_hhearn0206pre04 "Pre-treatment household earnings";
local title_n_hhearnpre03 "Pre-treatment household earnings";
local title_n_hhearn0206pre03 "Pre-treatment household earnings";
local title_n_tothhincpost04 "Total household income";
local title_n_tothhinc0206post04 "Total household income";
local title_n_tothhincpost03 "Total household income";
local title_n_tothhinc0206post03 "Total household income";
local title_n_tothhincpre04 "Pre-treatment total household income";
local title_n_tothhinc0206pre04 "Pre-treatment total household income";
local title_n_tothhincpre03 "Pre-treatment total household income";
local title_n_tothhinc0206pre03 "Pre-treatment total household income";
local title_n_hhearngt0 "Parental earnings > $0";
local title n_hhearngt10 "Parental earnings > $10K";
local title n_hhearngt20 "Parental earnings > $20K";
local title n_hhearngt30 "Parental earnings > $30K";
local title_cv_hhearns "Parent earnings volatility";
local title_cv_tothhinc "Household income volatility";
local title_n_delta_hhearnspost "Parent earnings change";
local title_n_delta_tothhincpost "Household income change";
local title_n_yrhhinclt10 "Number of years income less than $10K";
local title_n_yrhhinclt20 "Number of years income less than $20K";
local title_n_yrhhinclt30 "Number of years income less than $30K";
local title_gamma0_ce "Certainty equivalent {&gamma}=0";
local title_gamma10_ce "Certainty equivalent {&gamma}=1";
local title_gamma15_ce "Certainty equivalent {&gamma}=1.5";
local title_gamma20_ce "Certainty equivalent {&gamma}=2";
local title_gamma25_ce "Certainty equivalent {&gamma}=2.5";
local title_gamma30_ce "Certainty equivalent {&gamma}=3";
local title_gamma35_ce "Certainty equivalent {&gamma}=3.5";
local title_gamma40_ce "Certainty equivalent {&gamma}=4";
forval yr=1985(1)2011 {;
	local title_n_hhearns_`yr' "Parental earnings in `yr'";
	local title_n_hhearns0206_`yr' "Parental earnings in `yr'";
	local title_n_hhearngt0_`yr' "Earnings>0 in `yr'";
	local title_n_hhearngt00206_`yr' "Earnings>0 in `yr'";
	local title_n_hhearngt20_`yr' "Earnings>poverty in `yr'";
	local title_n_hhearngt200206_`yr' "Earnings>poverty in `yr'";
	local title_n_tothhinc_`yr' "Household income in `yr'";
	local title_n_tothhinc0206_`yr' "Household income in `yr'";
};
forval yr=2005(1)2013 {;
	local title_n_kidearns_`yr' "Child earnings in `yr'";
};

local ytitle_fy_2004 "Eligible for CDR in FY04";
local ytitle_n_cdr_rel "Released for a CDR in FY2004 or FY2005";
local ytitle_n_cdrunfav_18 "Unfavorable CDR before age 18";
local ytitle_n_paymon18 "Number of months on SSI before age 18";
local ytitle_n_combpay18 "Total SSI payment before age 18";
local ytitle_n_avgpay18 "Average annual SSI payment before age 18";
local ytitle_n_paymonpre "Months on SSI before 2003";
local ytitle_n_combpaypre "SSI payment before 2003";
local ytitle_n_hhunearn "Total HH unearned income post-CDR";
local ytitle_n_hhunearn0206 "Total HH unearned income post-CDR";
local ytitle_n_hhunearnwokid "HH unearned income (w/o kid SSI) post-CDR";
local ytitle_n_hhunearnwokid0206 "HH unearned income (w/o kid SSI) post-CDR";
local ytitle_n_hhdiamt "Parental DI receipt post-CDR";
local ytitle_n_hhdiamt0206 "Parental DI receipt post-CDR";
local ytitle_n_hhnumdi "Number of parents on DI post-CDR";
local ytitle_n_hhnumdi0206 "Number of parents on DI post-CDR";
local ytitle_n_hhssipay "Parental SSI receipt post-CDR";
local ytitle_n_hhssipay0206 "Parental SSI receipt post-CDR";
local ytitle_n_hhnumssi "Number of parents on SSI post-CDR";
local ytitle_n_hhnumssi0206 "Number of parents on SSI post-CDR";
local ytitle_n_sibssipay "Sibling SSI receipt post-CDR";
local ytitle_n_sibnumssi "Number of siblings on SSI post-CDR";
local ytitle_n_hhappdi "Number of parental DI apps post-CDR";
local ytitle_n_hhappdi0206 "Number of parental DI apps post-CDR";
local ytitle_n_hhappssi "Number of parental SSI apps post-CDR";
local ytitle_n_hhappssi0206 "Number of parental SSI apps post-CDR";
local ytitle_n_kidappdi "Number of child DI apps post-CDR";
local ytitle_n_kidappssi "Number of child SSI apps post-CDR";
local ytitle_n_sibappnum "Number of sibling SSI apps post-CDR";
forval yr=1985(1)2012 {; 
	local ytitle_n_paymon_`yr' "Months on SSI in `yr'";
	local ytitle_n_combpay_`yr' "Child's SSI payment in `yr'";
	local ytitle_n_hhcombpay_`yr' "Parental SSI receipt in `yr'";
	local ytitle_n_hhcombpay0206_`yr' "Parental SSI receipt in `yr'";
	local ytitle_n_sibpayall_`yr' "Sibling SSI receipt in `yr'";
	local ytitle_n_par831di_`yr' "Number of parents applying for DI in `yr'";
	local ytitle_n_par831di0206_`yr' "Number of parents applying for DI in `yr'";
	local ytitle_n_par831ssi_`yr' "Number of parents applying for SSI in `yr'";
	local ytitle_n_par831ssi0206_`yr' "Number of parents applying for SSI in `yr'";
	local ytitle_n_kid831_di_`yr' "Kid applies for DI in `yr'";
	local ytitle_n_kid831_ssi_`yr' "Kid applies for SSI in `yr'";
};
local ytitle_n_male "Male";
local ytitle_cdr_dobyy "Year of birth";
local ytitle_n_fiscalyob "Fiscal year of birth";
forval yr=1991(1)2004 {;
	local ytitle_n_yob_`yr' "Year of birth `yr'";
	local ytitle_n_fiscalyob_`yr' "Fiscal year of birth `yr'";
};
local ytitle_n_firstage "Age at initial SSI receipt";
forval i=0(1)11 {;
	local ytitle_n_firstage_`i' "Age `i' at initial SSI receipt";
};
local ytitle_n_diag1_none "No diagnosis";
local ytitle_n_diag1_infec "Infectious diagnosis";
local ytitle_n_diag1_neo "Neoplasm diagnosis";
local ytitle_n_diag1_endo "Endocrine diagnosis";
local ytitle_n_diag1_blood "Blood diagnosis";
local ytitle_n_diag1_mental "Mental diagnosis";
local ytitle_n_diag1_nerv "Nervous diagnosis";
local ytitle_n_diag1_sense "Sensory diagnosis";
local ytitle_n_diag1_circ "Circulatory diagnosis";
local ytitle_n_diag1_resp "Respiratory diagnosis";
local ytitle_n_diag1_dig "Digestive diagnosis";
local ytitle_n_diag1_gu "GU diagnosis";
local ytitle_n_diag1_skin "Skin diagnosis";
local ytitle_n_diag1_musc "Musculoskeletal diagnosis";
local ytitle_n_diag1_cong "Congenital diagnosis";
local ytitle_n_diag1_nat "Natal diagnosis";
local ytitle_n_diag1_ill "Ill-defined diagnosis";
local ytitle_n_diag1_inj "Injury diagnosis";

local ytitle_n_kidearnstot18 "Total child earnings after age 17";
local ytitle_n_kidearnsavg18 "Avg. ann. child earnings after age 17";
local ytitle_n_combpaytot18 "Total SSI payment after age 17";
local ytitle_n_combpayavg18 "Avg. ann. SSI payment after age 17";
local ytitle_n_hhearn18 "Parental earnings to age 18";
local ytitle_n_hhearn020618 "Parental earnings to age 18";
local ytitle_n_hhearnpost04 "Annual parental earnings post-CDR";
local ytitle_n_hhearn0206post04 "Annual parental earnings post-CDR";
local ytitle_n_hhearnpost03 "Annual parental earnings post-2003";
local ytitle_n_hhearn0206post03 "Annual parental earnings post-2003";
local ytitle_n_hhearnpre04 "Parental earnings pre-2004";
local ytitle_n_hhearn0206pre04 "Parental earnings pre-2004";
local ytitle_n_hhearnpre03 "Parental earnings pre-2003";
local ytitle_n_hhearn0206pre03 "Parental earnings pre-2003";
local ytitle_n_tothhincpost04 "Annual household income post-CDR";
local ytitle_n_tothhinc0206post04 "Annual household income post-CDR";
local ytitle_n_tothhincpost03 "Annual household income post-2003";
local ytitle_n_tothhinc0206post03 "Annual household income post-2003";
local ytitle_n_tothhincpre04 "Total household income pre-2004";
local ytitle_n_tothhinc0206pre04 "Total household income pre-2004";
local ytitle_n_tothhincpre03 "Total household income pre-2003";
local ytitle_n_tothhinc0206pre03 "Total household income pre-2003";
local ytitle_n_hhearngt0 "Parental earnings greater than $0K";
local ytitle_n_hhearngt10 "Parental earnings greater than $10K";
local ytitle_n_hhearngt20 "Parental earnings greater than $20K";
local ytitle_n_hhearngt30 "Parental earnings greater than $30K";
local ytitle_cv_hhearns "Coefficient of variation";
local ytitle_cv_tothhinc "Coefficient of variation";
local ytitle_n_delta_hhearnspost "Avg. absolute change from previous year";
local ytitle_n_delta_tothhincpost "Avg. absolute change from previous year";
local ytitle_n_yrhhinclt10 "Number of years";
local ytitle_n_yrhhinclt20 "Number of years";
local ytitle_n_yrhhinclt30 "Number of years";
local ytitle_gamma0_ce "Dollars";
local ytitle_gamma10_ce "Dollars";
local ytitle_gamma15_ce "Dollars";
local ytitle_gamma20_ce "Dollars";
local ytitle_gamma25_ce "Dollars";
local ytitle_gamma30_ce "Dollars";
local ytitle_gamma35_ce "Dollars";
local ytitle_gamma40_ce "Dollars";
forval yr=1985(1)2011 {;
	local ytitle_n_hhearns_`yr' "Parental earnings in `yr'";
	local ytitle_n_hhearns0206_`yr' "Parental earnings in `yr'";
	local ytitle_n_hhearngt0_`yr' "Earnings>0 in `yr'";
	local ytitle_n_hhearngt00206_`yr' "Earnings>0 in `yr'";
	local ytitle_n_hhearngt20_`yr' "Earnings>poverty in `yr'";
	local ytitle_n_hhearngt200206_`yr' "Earnings>poverty in `yr'";
	local ytitle_n_tothhinc_`yr' "Total household income (earnings, DI, SSI) in `yr'";
	local ytitle_n_tothhinc0206_`yr' "Total household income (earnings, DI, SSI) in `yr'";
};
forval yr=2005(1)2013 {;
	local ytitle_n_kidearns_`yr' "Child earnings in `yr'";
};

local abbr_fy_2004 "fy04";
local abbr_n_cdr_rel "rel";
local abbr_n_cdrunfav_18 "cdrunfav";
local abbr_n_paymon18 "months";
local abbr_n_combpay18 "pay";
local abbr_n_avgpay18 "avgpay";
local abbr_n_paymonpre "monthspre";
local abbr_n_combpaypre "paypre";
local abbr_n_hhunearn "hhunearn";
local abbr_n_hhunearn0206 "hhunearn0206";
local abbr_n_hhunearnwokid "hhunearnwokid";
local abbr_n_hhunearnwokid0206 "hhunearnwokid0206";
local abbr_n_hhdiamt "hhdiamt";
local abbr_n_hhdiamt0206 "hhdiamt0206";
local abbr_n_hhnumdi "hhnumdi";
local abbr_n_hhnumdi0206 "hhnumdi0206";
local abbr_n_hhssipay "hhssipay";
local abbr_n_hhssipay0206 "hhssipay0206";
local abbr_n_hhnumssi "hhnumssi";
local abbr_n_hhnumssi0206 "hhnumssi0206";
local abbr_n_sibssipay "sibssipay";
local abbr_n_sibnumssi "sibnumssi";
local abbr_n_hhappdi "hhappdi";
local abbr_n_hhappdi0206 "hhappdi0206";
local abbr_n_hhappssi "hhappssi";
local abbr_n_hhappssi0206 "hhappssi0206";
local abbr_n_tothhincpost "tothhinc";
local abbr_n_tothhinc0206post "tothhinc0206";
local abbr_n_kidappdi "kidappdi";
local abbr_n_kidappssi "kidappssi";
local abbr_n_sibappnum "sibappnum";
forval yr=1985(1)2012 {; 
	local abbr_n_paymon_`yr' "month`yr'";
	local abbr_n_combpay_`yr' "pay`yr'";
	local abbr_n_hhcombpay_`yr' "hhssi`yr'";
	local abbr_n_hhcombpay0206_`yr' "hhssi0206`yr'";
	local abbr_n_sibpayall_`yr' "sibssi`yr'";
	local abbr_n_par831di_`yr' "hhappdi`yr'";
	local abbr_n_par831di0206_`yr' "hhappdi0206`yr'";
	local abbr_n_par831ssi_`yr' "hhappssi`yr'";
	local abbr_n_par831ssi0206_`yr' "hhappssi0206`yr'";
	local abbr_n_kid831_di_`yr' "kidappdi`yr'";
	local abbr_n_kid831_ssi_`yr' "kidappssi`yr'";
};

local abbr_n_male "male";
local abbr_cdr_dobyy "yob";
local abbr_n_fiscalyob "fyob";
forval yr=1991(1)2004 {;
	local abbr_n_yob_`yr' "yob`yr'";
	local abbr_n_fiscalyob_`yr' "fyob`yr'";
};
local abbr_cdr_dob_sas "exactdob";
local abbr_n_firstage "firstage";
forval i=0(1)11 {;
	local abbr_n_firstage_`i' "firstage`i'";
};
local abbr_n_diag1_none "nodiag";
local abbr_n_diag1_infec "infec";
local abbr_n_diag1_neo "neo";
local abbr_n_diag1_endo "endo";
local abbr_n_diag1_blood "blood";
local abbr_n_diag1_mental "ment";
local abbr_n_diag1_nerv "nerv";
local abbr_n_diag1_sense "sense";
local abbr_n_diag1_circ "circ";
local abbr_n_diag1_resp "resp";
local abbr_n_diag1_dig "dig";
local abbr_n_diag1_gu "gu";
local abbr_n_diag1_skin "skin";
local abbr_n_diag1_musc "musc";
local abbr_n_diag1_cong "cong";
local abbr_n_diag1_nat "nat";
local abbr_n_diag1_ill "ill";
local abbr_n_diag1_inj "inj";

local abbr_n_kidearnstot18 "kidearntot18";
local abbr_n_kidearnsavg18 "kidearnavg18";
local abbr_n_combpaytot18 "combpaytot18";
local abbr_n_combpayavg18 "combpayavg18";
local abbr_n_hhearn18 "hhearn18";
local abbr_n_hhearn020618 "hhearn020618";
local abbr_n_hhearnpost04 "hhearnpost04";
local abbr_n_hhearn0206post04 "hhearn0206post04";
local abbr_n_hhearnpost03 "hhearnpost03";
local abbr_n_hhearn0206post03 "hhearn0206post03";
local abbr_n_hhearnpre04 "hhearnpre04";
local abbr_n_hhearn0206pre04 "hhearn0206pre04";
local abbr_n_hhearnpre03 "hhearnpre03";
local abbr_n_hhearn0206pre03 "hhearn0206pre03";
local abbr_n_tothhincpost04 "tothhincpost04";
local abbr_n_tothhinc0206post04 "tothhinc0206post04";
local abbr_n_tothhincpost03 "tothhincpost03";
local abbr_n_tothhinc0206post03 "tothhinc0206post03";
local abbr_n_tothhincpre04 "tothhincpre04";
local abbr_n_tothhinc0206pre04 "tothhinc0206pre04";
local abbr_n_tothhincpre03 "tothhincpre03";
local abbr_n_tothhinc0206pre03 "tothhinc0206pre03";
local abbr_n_hhearngt0 "hhearngt0";
local abbr_n_hhearngt10 "hhearngt10";
local abbr_n_hhearngt20 "hhearngt20";
local abbr_n_hhearngt30 "hhearngt30";
local abbr_cv_hhearns "cvhhearns";
local abbr_cv_tothhinc "cvtothhinc";
local abbr_n_delta_hhearnspost "delthhearns";
local abbr_n_delta_tothhincpost "delttothhinc";
local abbr_n_yrhhinclt10 "yrhhinclt10";
local abbr_n_yrhhinclt20 "yrhhinclt20";
local abbr_n_yrhhinclt30 "yrhhinclt30";
local abbr_gamma0_ce "ce00";
local abbr_gamma10_ce "ce10";
local abbr_gamma15_ce "ce15";
local abbr_gamma20_ce "ce20";
local abbr_gamma25_ce "ce25";
local abbr_gamma30_ce "ce30";
local abbr_gamma35_ce "ce35";
local abbr_gamma40_ce "ce40";
forval yr=1985(1)2011 {;
	local abbr_n_hhearns_`yr' "hhearns`yr'";
	local abbr_n_hhearns0206_`yr' "hhearns0206`yr'";
	local abbr_n_hhearngt0_`yr' "hhearngt0`yr'";
	local abbr_n_hhearngt00206_`yr' "hhearngt00206`yr'";
	local abbr_n_hhearngt20_`yr' "hhearngt20`yr'";
	local abbr_n_hhearngt200206_`yr' "hhearngt200206`yr'";
	local abbr_n_tothhinc_`yr' "tothhinc`yr'";
	local abbr_n_tothhinc0206_`yr' "tothhinc0206`yr'";
};
forval yr=2005(1)2013 {;
	local abbr_n_kidearns_`yr' "kidearns`yr'";
};

local ysc_n_hhearn020618 "r(160000 223000)";
local ysc_n_hhearn0206post04 "r(12000 16300)";
local ysc_n_hhearn0206post03 "r(11700 16300)";
local ysc_n_hhearn0206pre04 "r(6000 9300)";
local ysc_n_hhearn0206pre03 "r(6000 9300)";
local ysc_n_tothhinc0206post04 "r(22000 26300)";
local ysc_n_tothhinc0206post03 "r(22000 26300)";
local ysc_n_tothhinc0206pre04 "r(8000 12000)";
local ysc_n_tothhinc0206pre03 "r(7800 11300)";
local ysc_n_hhearns0206_2000 "r(14000 18000)";
local ysc_n_hhearns0206_2001 "r(12000 16500)";
local ysc_n_hhearns0206_2002 "r(12000 16000)";
local ysc_n_hhearns0206_2003 "r(12000 16500)";
local ysc_n_hhearns0206_2004 "r(12000 17500)";
local ysc_n_hhearns0206_2005 "r(13000 18500)";
local ysc_n_hhearns0206_2006 "r(14000 19500)";
local ysc_n_hhearns0206_2007 "r(15000 20500)";
local ysc_n_hhearns0206_2008 "r(14000 20500)";
local ysc_n_hhearns0206_2009 "r(14000 20000)";
local ysc_n_hhearns0206_2010 "r(13000 19700)";
local ysc_n_hhearns0206_2011 "r(13000 19700)";
local ysc_cv_hhearns "r(.7 .9)";
local ysc_cv_tothhinc "r(0.28 0.36)";

local ylabel_n_hhearn020618 "160000(20000)220000";
local ylabel_n_hhearn0206post04 "12000(1000)16000";
local ylabel_n_hhearn0206post03 "12000(1000)16000";
local ylabel_n_hhearn0206pre04 "6000(1000)9000";
local ylabel_n_hhearn0206pre03 "6000(1000)9000";
local ylabel_n_tothhinc0206post04 "22000(1000)26000";
local ylabel_n_tothhinc0206post03 "22000(1000)26000";
local ylabel_n_tothhinc0206pre04 "8000(1000)12000";
local ylabel_n_tothhinc0206pre03 "8000(1000)11000";
local ylabel_n_hhearns0206_2000 "14000(1000)18000";
local ylabel_n_hhearns0206_2001 "12000(1000)16000";
local ylabel_n_hhearns0206_2002 "12000(1000)16000";
local ylabel_n_hhearns0206_2003 "12000(1000)16000";
local ylabel_n_hhearns0206_2004 "12000(1000)17000";
local ylabel_n_hhearns0206_2005 "13000(1000)18000";
local ylabel_n_hhearns0206_2006 "14000(1000)19000";
local ylabel_n_hhearns0206_2007 "15000(1000)20000";
local ylabel_n_hhearns0206_2008 "14000(2000)20000";
local ylabel_n_hhearns0206_2009 "14000(2000)20000";
local ylabel_n_hhearns0206_2010 "13000(2000)19000";
local ylabel_n_hhearns0206_2011 "13000(2000)19000";
local ylabel_cv_hhearns ".7(.05).9";
local ylabel_cv_tothhinc "0.28(.02)0.36";

local ttext1_n_hhearn020618 "ttext(222000 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearn0206post04 "ttext(16200 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearn0206post03 "ttext(16200 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearn0206pre04 "ttext(9200 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearn0206pre03 "ttext(9200 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_tothhinc0206post04 "ttext(26200 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_tothhinc0206post03 "ttext(26200 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_tothhinc0206pre04 "ttext(11800 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_tothhinc0206pre03 "ttext(11200 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearns0206_2000 "ttext(17800 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearns0206_2001 "ttext(16250 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearns0206_2002 "ttext(15800 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearns0206_2003 "ttext(16250 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearns0206_2004 "ttext(17300 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearns0206_2005 "ttext(18300 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearns0206_2006 "ttext(19300 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearns0206_2007 "ttext(20300 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearns0206_2008 "ttext(20300 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearns0206_2009 "ttext(19750 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearns0206_2010 "ttext(19500 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_n_hhearns0206_2011 "ttext(19500 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_cv_hhearns "ttext(.89 2001w20 "Review more likely (less SSI)", color(black))";
local ttext1_cv_tothhinc "ttext(.355 2001w20 "Review more likely (less SSI)", color(black))";

local ttext2_n_hhearn020618 "ttext(222000 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearn0206post04 "ttext(16200 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearn0206post03 "ttext(16200 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearn0206pre04 "ttext(9200 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearn0206pre03 "ttext(9200 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_tothhinc0206post04 "ttext(26200 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_tothhinc0206post03 "ttext(26200 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_tothhinc0206pre04 "ttext(11800 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_tothhinc0206pre03 "ttext(11200 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearns0206_2000 "ttext(17800 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearns0206_2001 "ttext(16250 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearns0206_2002 "ttext(15800 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearns0206_2003 "ttext(16250 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearns0206_2004 "ttext(17300 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearns0206_2005 "ttext(18300 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearns0206_2006 "ttext(19300 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearns0206_2007 "ttext(20300 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearns0206_2008 "ttext(20300 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearns0206_2009 "ttext(19750 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearns0206_2010 "ttext(19500 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_n_hhearns0206_2011 "ttext(19500 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_cv_hhearns "ttext(.89 2002w7 "Review less likely (more SSI)", color(black))";
local ttext2_cv_tothhinc "ttext(.355 2002w7 "Review less likely (more SSI)", color(black))";


/* ******************* */
/* **** RD GRAPHS **** */
/* ******************* */
use "`data'\statsby\restat_analysis_rd_earn_graphs.dta", clear;		
keep if abs(awdwk_run)<35;

/* Plot running variable (award date) against... */
tsset awd`time'_stata, `unit';
gen cutoff_dte=mdy(10,01,2001);
gen cutoff_wk=wofd(mdy(10,01,2001));

/* RD graphs for outcomes */
foreach var of varlist 
					n_hhearn020618 n_hhearn0206post04 n_hhearn0206post03 n_tothhinc0206post04 n_tothhinc0206post03
					n_hhearn0206pre04 n_hhearn0206pre03 n_tothhinc0206pre04 n_tothhinc0206pre03
					cv_hhearns cv_tothhinc
					n_hhearns0206_2000-n_hhearns0206_2011
	{;
	twoway  
		(scatter `var' awd`time'_stata if awdwk_run<0 | awdwk_run>=5, mcolor(black)) 
		(scatter `var' awd`time'_stata if awdwk_run>=0 & awdwk_run<5, mcolor(gs10)) 
		(qfit `var' awd`time'_stata if awd`time'_stata<cutoff_`time', lcolor(black)) 
		(qfit `var' awd`time'_stata if awd`time'_stata>=cutoff_`time' & (awdwk_run<0 | awdwk_run>=5), lcolor(black)), 
		title("`title_`var''", size(medsmall)) 
		xtitle("Award date", size(medsmall)) 
		ytitle("`ytitle_`var''", size(medsmall))
		ysc(`ysc_`var'') ylabel(`ylabel_`var'',nogrid)
		legend(off) 
		tlabel(`tlabel_`time'') 
		tline(`tline_`time'')
		`ttext1_`var''
		`ttext2_`var''
		graphregion(color(white))
		bgcolor(white)
		;
	graph save "`output'\restat_`exp'_`abbr_`var''", replace;
	pause;
	};
	
log close;
